﻿using System.Globalization;
using KinonekoSoftware.Foundation.UI.Media;

namespace KinonekoSoftware.Foundation.UI.Converters
{
#if AVALONIA

    using Avalonia.Data.Converters;
    
#else
    using System.Windows.Data;
    
#endif
    
    public class StringToColorConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var v = value?.ToString();
            return MediaFactory.ToColor(v);
        }
        
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return value?.ToString();
        }
    }
}